// pages/myStudentInfo/myStudentInfo.js
let userModel = require('../../models/user.js')
let relation = null

Page({

  /**
   * 页面的初始数据
   */
  data: {
    relation:{},
    editButtonDesc:"更改关系"
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let user = userModel.getCurrentUser()
    relation = getApp().globalData.param
    relation.student.gender = userModel.getStudentGender(relation.student)
    if (relation.student.creatorSid == user.sid) {
      this.setData({
        editButtonDesc:'编辑学生'
      })
    }

    this.setData({
      relation: relation
    })
  },


  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    relation = null  
  },

  onEditStudent:function() {
    getApp().globalData.param = relation.student
    wx.navigateTo({
      url: '../editStudent/editStudent?studentSid=' + relation.student.sid,
    })
  },

  onDelRelation:function() {
    wx.navigateTo({
      url: '../removeRelation/removeRelation?relationSid=' + relation.sid,
    })
  }
})